<?php

Class Cabang extends CI_Controller
{
	function __construct()
	{
		parent::__construct();
		$this->load->model('data/mcabang');		
	}

	function index()
	{
		$this->tampil();
	}

	function tampil()
	{
		$data['tampil'] = $this->mcabang->daftar_cabang();
		$this->load->view('data/vcabang',$data);
	}

	function new_cabang()
	{
		$this->load->view('data/vnew_cabang');
	}
	
	
	//fungsi untuk simpan
	function simpan(){
		$nama   = $this->input->post('nama');
		$alamat = $this->input->post('alamat');
		$kota   = $this->input->post('kota');
		$kodepos   = $this->input->post('kodepos');
		$tlp    = $this->input->post('tlp');
		$fax    = $this->input->post('fax');
		$kepala_outlet    = $this->input->post('kepala_outlet');
		$hp     = $this->input->post('hp');
		$date_reg     = $this->input->post('date_reg');
		$npwp     = $this->input->post('npwp');
		
		$cabang_id = $this->mcabang->create_cabang_id();
		
		//$poli   = 1;
		$this->mcabang->simpan($cabang_id,$nama,$alamat,$kota,$kodepos,$tlp,$fax,$kepala_outlet,$hp,$date_reg,$npwp);
		
		redirect('data/cabang/new_cabang');
	}
}